from django.db import connection
with connection.cursor() as c:
c.execute(
'select year(joined_date) year, month(joined_date) month, count(*) total '
'from c4_user_sys_account group by year, month order by year, month')
fetchall = c.fetchall()
items = []
for row in fetchall:
item = {}
item["year"] = row[0]
item["month"] = row[1]
item["total"] = row[2]
items.append(item)
